package com.edgclub.edg.adapter.adapteruitls;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.widget.RecyclerView;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;

import com.edgclub.edg.R;
import com.edgclub.edg.model.result.TopicDetailData;

import java.util.ArrayList;

/**
 */
    public  abstract class GzBaseAdapter extends RecyclerView.Adapter{
        public GzBaseAdapter() {
            super();
        }


    public MyItemClickListener mListener;
    public MyItemLongClickListener mLongClickListener;
    /**
     * 设置Item点击监听
     * @param listener
     */
    public void setOnItemClickListener(MyItemClickListener listener){
        this.mListener = listener;
    }

    public void setOnItemLongClickListener(MyItemLongClickListener listener){
        this.mLongClickListener = listener;
    }

    android.app.Dialog dialog;
    private Animation anim;
    /**
     * 显示dialog
     *
     * @param message
     */
    private ImageView load_image;

    public void showDialog(Context context, String message, boolean isCanCancel) {
        anim = AnimationUtils.loadAnimation(context, R.anim.my_anim);
        LinearInterpolator lir = new LinearInterpolator();
        anim.setInterpolator(lir);
        dialog = new android.app.Dialog(context, R.style.dialog);
        dialog.show();
        Window window = dialog.getWindow();
        window.setContentView(R.layout.showdialog_layout);
        load_image = (ImageView) window.findViewById(R.id.load_image1);
        TextView load_text = (TextView) window.findViewById(R.id.load_text);
        load_text.setText(message);
        dialog.setCanceledOnTouchOutside(isCanCancel);
        load_image.startAnimation(anim);
    }


    /**
     * 取消dialog
     */
    public void dismissDialog() {
        if (null != anim)
            anim.cancel();
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
    }

    protected void dialogCancel(DialogInterface dialog) {
        if (null != anim)
            anim.cancel();
        if (null != dialog) {
            dialog.dismiss();
        }
    }



}
